* draw time series plot
clear all
version 16.1

global ci_setting1 = " fc(gs6%20) alp(solid) alc(gs9) alw(vthin) lwidth(medthick)"
global ci_setting2 = " fc(gs9%20) alp(solid) alc(gs13) alw(vthin) lwidth(medthick)"

global graphop legend(off/*order(2 "Treatment" 4 "Control")*/) xtitle("") ///
xlabel(20180 20545 20910 21275 21640 22006 22371, nogrid) graphregion(c(white)) ///
tlabel(,format(%tdMonYY)) tline(12feb2019,lc(black)) 


use ../tmp/sample_090122.dta, clear
do modules/__sample_for_timeseries.do

*** prob above reserve ***
twoway(lpolyci abovereserve MDYbid if auction_tr == 1, lc(gs3) lwidth(medthick) $ci_setting1) ///
(lpolyci abovereserve MDYbid if auction_tr == 0, lc(gs11) lwidth(medthick) $ci_setting2) ///
if MDYbid >= td(01Apr2015) & MDYbid < td(01apr2021) & winner != 1, ///
$graphop title("Pr(Losing Bids > Reserve)") ylabel(0(.2)1,angle(0)) xsize(6) ysize(5) 
graph export ../graph/twowaylpoly_abovereserve_timeseries.png, replace

*** quality ***
twoway(lpolyci q MDYbid if auction_treatment == 1, lc(gs3) lwidth(medthick) $ci_setting1) ///
	(lpolyci q MDYbid if auction_treatment == 0, lc(gs11) lwidth(medthick) $ci_setting2) ///
if MDYbid >= td(01Apr2015) & MDYbid < td(01apr2021) & winner != 1, ytitle("Raw Quality") ///
$graphop title("Losing Bidders") ylabel(120(10)160,angle(0)) ///
xsize(5) ysize(5) 
graph export ../graph/twowaylpoly_q_losers_timeseries.png, replace

twoway(lpolyci q MDYbid if auction_treatment == 1, lc(gs3) lwidth(medthick) $ci_setting1) ///
	(lpolyci q MDYbid if auction_treatment == 0, lc(gs11) lwidth(medthick) $ci_setting2) ///
if MDYbid >= td(01Apr2015) & MDYbid < td(01apr2021) & winner == 1, ytitle("Raw Quality") ///
$graphop title("Winning Bidders") ylabel(120(10)160,angle(0)) ///
xsize(5) ysize(5) 
graph export ../graph/twowaylpoly_q_winners_timeseries.png, replace

*** price ***
twoway(lpolyci pctbid MDYbid if auction_tr == 1, lc(gs3) lwidth(medthick) $ci_setting1 yline(1, lc(black))) ///
	(lpolyci pctbid MDYbid if auction_treatment == 0, lc(gs11) lwidth(medthick) $ci_setting2) ///
if MDYbid >= td(01Apr2015) & MDYbid < td(01apr2021) & winner == 1, ytitle("Normalized Bids") ///
$graphop title("Winning Bidders") ylabel(.8(.1)1.1,angle(0)) xsize(5) ysize(5) 
graph export ../graph/twowaylpoly_winbidpct_timeseries.png, replace

twoway(lpolyci pctbid MDYbid if auction_tr == 1, lc(gs3) lwidth(medthick) $ci_setting1 yline(1, lc(black))) ///
	(lpolyci pctbid MDYbid if auction_treatment == 0, lc(gs11) lwidth(medthick) $ci_setting2) ///
if MDYbid >= td(01Apr2015) & MDYbid < td(01apr2021) & winner != 1, ytitle("Normalized Bids") xsize(5) ysize(5)  ///
$graphop title("Losing Bidders") ylabel(.8(.1)1.1,angle(0)) 
graph export ../graph/twowaylpoly_pctlosingbids_timeseries.png, replace
